package com.example.langchain4j_springboot.controller.Hight;

import com.example.langchain4j_springboot.Service.HeighAssitant;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.memory.ChatMemory;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static dev.langchain4j.data.message.AiMessage.aiMessage;

@RestController
@RequestMapping("/hight_chat")
@RequiredArgsConstructor
public class demoController {
    public final HeighAssitant heighAssitant;

    public final ChatMemory chatMemory;
    public final QwenChatModel qwenChatModel;
    @RequestMapping("/demo")
    public String demo(String message) {
        chatMemory.add(new UserMessage(message));

        String text = qwenChatModel.chat(chatMemory.messages())
                .aiMessage()
                .text();
        chatMemory.add(new AiMessage(text));
        return text;
    }
}
